{extend name="property/public/insidePageBase" /}
{block name="title"}租赁详情{/block}
{block name="body"}
<div class="layuimini-container">
    <div class="layuimini-main">
        <div class="layui-form  layui-form-pane">
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <ul class="layui-tab-title">
                    <li class="layui-this">租赁信息 <span class="layui-badge layui-bg-cyan" style="color: red;">{if $contractInfo.sign_type == 1} 电子合同 {else/} 纸质合同{/if} </span></li>
                    <li>租赁日志</li>
                    {if $contractInfo.status != 3  || $contractInfo.status != 5}
                    <button class="layui-btn layui-btn-normal layui-btn-sm editContract"> 编辑 </button>
                    {/if}
                    {if $contractInfo.status == 2}
                        {if $extendAuth}<button class="layui-btn layui-btn-normal layui-btn-sm extendContract"> 续租 </button> {/if}
                        {if $renunAuth}<button class="layui-btn layui-btn-normal layui-btn-sm renunContract"> 退租 </button> {/if}
                    {/if}
                    {if $contractInfo.status == 1}
                        {if $auditAuth}
                            <a class="layui-btn layui-btn-normal layui-btn-sm auditContract">租赁审核</a>
                        {/if}
                    {/if}
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <!--租赁信息 add-->
                        <div class="layui-row">
                            <div class="layui-col-xs4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">租赁周期</label>
                                    <div class="layui-input-block">
                                        <input type="text" value="{$contractInfo['start_date']??''} - {$contractInfo['end_date']??''}" disabled autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-xs4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">租赁编号</label>
                                    <div class="layui-input-block">
                                        <input type="text" value="{$contractInfo['number']}" disabled autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-xs3">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">银行手续费</label>
                                    <div class="layui-input-block">
                                        <input type="text" value="{if $contractInfo.out_fee_flag == 1}甲方{else/}乙方{/if} 承担" disabled autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <ul class="layui-tab-title">
                            <li class="layui-this">同住用户信息</li>
                            <button class="layui-btn layui-btn-primary layui-border contractLesseeAdd"> 添加新住户 </button>
                        </ul>
                        <table class="layui-hide" id="contractLesseeList" lay-filter="contractLesseeList"></table>
                        <script type="text/html" id="tableContractLesseeDataBar">
                            <div class="layui-btn-group">
                                <a class="layui-btn layui-btn-sm layui-btn-primary layui-border" lay-event="contractLesseeEdit">编辑</a>
                                <a class="layui-btn layui-btn-sm layui-btn-primary layui-border" lay-event="contractLesseeDetail">详情</a>
                                {{# if(d.is_owner != 1) { }}
                                <a class="layui-btn layui-btn-sm layui-btn-danger" lay-event="contractLesseeDel">删除</a>
                                {{# } }}
                            </div>
                        </script>
                        <script type="text/html" id="is_type_tpl">
                            {{# if(d.is_type === 1) { }}<span class="layui-badge layui-bg-cyan">身份证</span>{{# } }}
                            {{# if(d.is_type === 2) { }}<span class="layui-badge layui-bg-cyan">护照</span>{{# } }}
                            {{# if(d.is_type === 3) { }}<span class="layui-badge layui-bg-cyan">港澳通行证 </span>{{# } }}
                            {{# if(d.is_type === 4) { }}<span class="layui-badge layui-bg-cyan">回乡证</span>{{# } }}
                            {{d.number}}
                        </script>
                        <script type="text/html" id="is_owner_tpl">
                            {{# if(d.is_owner === 1) { }}<span class="layui-badge layui-bg-green">签约住户</span>{{# } }}
                            {{# if(d.is_owner === 2) { }}<span class="layui-badge layui-bg-orange">同住人员</span>{{# } }}
                        </script>

                        <ul class="layui-tab-title">
                            <li class="layui-this">费用明细列表</li>
                            <button class="layui-btn layui-btn-primary layui-border contractBillAdd"> 添加费用 </button>
                        </ul>
                        <table class="layui-hide" id="contractBillData" lay-filter="contractBillData"></table>
                        <script type="text/html" id="tableContractBillDataBar">
                            <div class="layui-btn-group">
                                {{# if(d.status === 1) { }}
                                <a class="layui-btn layui-btn-sm layui-btn-primary layui-border" lay-event="contractBillDataEdit">编辑</a>
                                {{# } }}
                                {{# if(d.if_del === 2) { }}
                                <a class="layui-btn layui-btn-sm layui-btn-primary layui-border" lay-event="contractBillDataDel">删除</a>
                                {{# } }}
                            </div>
                        </script>
                        <script type="text/html" id="contract_bill_status_tpl">
                            {{# if(d.status === 1) { }}<span class="layui-badge layui-bg-cyan">执行中</span>{{# } }}
                            {{# if(d.status === 9) { }}<span class="layui-badge layui-bg-green">己完成</span>{{# } }}
                        </script>


                        <ul class="layui-tab-title">
                            <li class="layui-this">关联房间信息</li>
                            {if $boundRoomBillAuth}<button class="layui-btn layui-btn-primary layui-border roomBound"> 关联房间 </button> {/if}
                        </ul>
                        <table class="layui-hide" id="roomContractList" lay-filter="roomContractList"></table>
                        <script type="text/html" id="tableRoomContractBar">
                            <div class="layui-btn-group">
                                <a class="layui-btn layui-btn-sm layui-btn-primary layui-border" lay-event="roomRelieve">解除绑定</a>
                                <a class="layui-btn layui-btn-sm layui-btn-primary layui-border" lay-event="roomDetail">详情</a>
                            </div>
                        </script>

                        <div class="layui-form-item layui-form-text">
                            <label class="layui-form-label"> <b style="color: red;"> 每月 {$contractInfo['bill_add_day']}  号生成账单，生成后 {$contractInfo['bill_pay_day']} 日内完成支付，逾期后每日账单总额的 {$contractInfo['overdue_fine']} % 支付滞纳金 ，最高不超过账单总额</b></label>
                            <div class="layui-input-block">
                                <textarea placeholder="{$contractInfo['remark']??''}" disabled class="layui-textarea"></textarea>
                            </div>
                        </div>
                        <!--租赁信息 end-->
                        <!--账单列表 add-->
                        <ul class="layui-tab-title">
                            <li class="layui-this">待支付账单信息</li>
                            <button class="layui-btn layui-btn-primary layui-border calendarBill"> 历吏账单 </button>
                        </ul>
                        <table class="layui-hide" id="contractBillList" lay-filter="contractBillList"></table>
                        <script type="text/html" id="tableBillListBar">
                            <div class="layui-btn-group">
                                {if $detailBillAuth}<a class="layui-btn layui-btn-sm" lay-event="detailsContractBill">详情</a>{/if}
                            </div>
                        </script>
                        <script type="text/html" id="bill_status_tpl">
                            {{# if(d.bill_type === 1) { }}<span class="layui-badge layui-bg-cyan">租金</span>{{# } }}
                            {{# if(d.bill_type === 2) { }}<span class="layui-badge layui-bg-green">退租</span>{{# } }}
                            {{# if(d.bill_type === 4) { }}<span class="layui-badge layui-bg-blue">记账</span>{{# } }}
                            {{# if(d.bill_type === 9) { }}<span class="layui-badge layui-bg-orange">押金</span>{{# } }}


                            {{# if(d.status === 1) { }}<span class="layui-badge layui-bg-cyan">待审核</span>{{# } }}
                            {{# if(d.status === 2) { }}<span class="layui-badge layui-bg-green">待支付</span>{{# } }}
                            {{# if(d.status === 3) { }}<span class="layui-badge layui-bg-blue">待确认</span>{{# } }}
                            {{# if(d.status === 9) { }}<span class="layui-badge layui-bg-orange">己完成</span>{{# } }}
                        </script>
                        <!--账单列表 end-->
                    </div>

                    <div class="layui-tab-item">
                        <!--租赁日志 add-->
                        <table class="layui-hide" id="contractLogList" lay-filter="contractLogList"></table>
                        <!--租赁日志 end-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
{__block__}
<script>
    layui.use(['form', 'layer', 'table','upload'], function () {
        var form = layui.form,layer = layui.layer,  $ = layui.$, table = layui.table,upload = layui.upload;
        let contractId = {$contractInfo['id']};
        let propertyId = {$contractInfo['property_id']};
        // 租赁信息 add
        $('.editContract').on('click', function() {
            var url = '{:url("propertyContractBasicEdit")}?id='+contractId;
            var index = layer.open({title:'{$contractInfo[\'number\']??''}  租赁编辑', type: 2, shade: 0.2,maxmin:true, area:['1000px', '90%'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                    var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                    iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                        var field = data.field; //获取提交的字段
                        var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                        $.post(url, field, function (res) {
                            layer.close(loadAdd);
                            if (res.code === 0) {
                                location.reload();//刷新当前页
                                layer.close(index); //关闭弹层
                                layer.msg(res.msg, {icon: 6, offset: '15px'});
                            } else {
                                layer.msg(res.msg, {icon: 5, offset: '15px'});
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        });
        // 租赁续租
        $('.extendContract').on('click', function() {
            var url = '{:url("propertyContractBasicExtend")}?contract_id='+contractId;
            var index = layer.open({title: '租赁续租', type: 2, shade: 0.2,maxmin:true, area:['450px', '500px'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                    var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                    iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                        var field = data.field; //获取提交的字段
                        var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                        $.post(url, field, function (res) {
                            layer.close(loadAdd);
                            if (res.code === 0) {
                                parent.layer.msg(res.msg, {icon: 6, offset: '15px',time: 1000}, function() {
                                    window.location.reload();
                                });
                            } else {
                                layer.msg(res.msg, {icon: 5, offset: '15px'});
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        });
        // 租赁退租
        $('.renunContract').on('click', function() {
            var url = '{:url("propertyContractBasicRenun")}?contract_id='+contractId;
            var index = layer.open({title: '租赁退租', type: 2, shade: 0.2,maxmin:true, area:['650px', '350px'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                    var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                    iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                        var field = data.field; //获取提交的字段
                        var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                        $.post(url, field, function (res) {
                            layer.close(loadAdd);
                            if (res.code === 0) {
                                parent.layer.msg(res.msg, {icon: 6, offset: '15px',time: 1000}, function() {
                                    window.location.reload();
                                });
                            } else {
                                layer.msg(res.msg, {icon: 5, offset: '15px'});
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        });
        $('.auditContract').on('click', function() {
            var url = '{:url("propertyContractBasicAudit")}';
            layer.confirm('是否确认审核通过? ', {icon: 3}, function () {
                var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                $.post(url, {id: {$contractInfo['id']}}, function (res) {
                    layer.close(loadAdd);
                    if (res.code === 0) {
                        parent.layer.msg(res.msg, {icon: 6, offset: '15px',time: 1000}, function() {
                            window.location.reload();
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5, offset: '15px'});
                    }
                });
            });
        });
        // 房间关联
        $('.roomBound').on('click', function() {
            var url = '{:url("propertyContractRoomBound")}?contract_id='+contractId;
            var index = parent.layer.open({title: '房间关联', type: 2, shade: 0.2,maxmin:true, area: ['500px', '600px'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                    var iframeWindow = parent.window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                    var field = {room_id:iframeWindow.roomId}; //获取提交的字段
                    var loadAdd = parent.layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                    $.post(url, field, function (res) {
                        parent.layer.close(loadAdd);
                        if (res.code === 0) {
                            layer.close(index);
                            table.reload(index); //数据刷新
                            parent.layer.close(index); //关闭弹层
                            parent.layer.msg(res.msg, {icon: 6, offset: '15px',time: 1000}, function() {
                                window.location.reload();
                            });
                        } else {
                            parent.layer.msg(res.msg, {icon: 5, offset: '15px'});
                        }
                    });
                }
            });
            return false;
        });
        // 租赁信息 end 

        // 账单列表 add 
        var tableBillListId = 'contractBillList';
        table.render({
            elem: '#'+tableBillListId,
            id:tableBillListId,
            url: '{:url("propertyBillStayPaymentList")}?contract_id='+contractId,
            cols: [[
                {field: 'status', width: 128, title: '类型 / 状态',  sort: true, templet:'#bill_status_tpl'},
                {field: 'number', width: 168, title: '账单编号', sort: true},
                {field: 'ar_amount', width: 105, title: '应缴金额', templet:function(d) {
                        return d.ar_amount + ' ¥';
                    },sort: true},
                {field: 'minus_amount', width: 105, title: '优惠金额', templet:function(d) {
                        return d.minus_amount + ' ¥';
                    },sort: true},
                {field: 'total_amount', width: 105, title: '实缴金额', templet:function(d) {
                        return d.total_amount + ' ¥';
                    },sort: true},
                {field: 'check_amount', width: 105, title: '己收金额', templet:function(d) {
                        return d.check_amount + ' ¥';
                    },sort: true},
                {field: 'add_time', width: 168, title: '创建时间', sort: true},
                {title: '操作', minWidth: 88, toolbar: '#tableBillListBar', fixed:'right'}
            ]],
        });
        table.on('rowDouble('+tableBillListId+')', function(obj){
            var data = obj.data;
            var url = '{:url("propertyBillBasicDetail")}?bill_id='+data.id;
            parent.layer.open({
                title: data.full_room_name + data.number +'  账单详情', type: 2, shade: 0.2, maxmin:true, shadeClose:true, move:false,area: ['1000px', '100%'],offset:  'rt', anim: 2, content: url , btn: false
            });
        });

        table.on('tool('+tableBillListId+')', function (obj) {
            var data = obj.data;
            if (obj.event === 'detailsContractBill') {
                var url = '{:url("propertyBillBasicDetail")}?bill_id='+data.id;
                parent.layer.open({
                    title: data.full_room_name + data.number +'  账单详情', type: 2, shade: 0.2, maxmin:true, shadeClose:true, move:false,area: ['1000px', '100%'],offset:  'rt', anim: 2, content: url , btn: false
                });
            }
        });
        // 历吏账单
        $('.calendarBill').on('click', function() {
            var url = '{:url("propertyBillBasicList")}?contract_id='+contractId;
            parent.layer.open({
                title: '{$contractInfo[\'number\']??''}历吏账单', type: 2, shade: 0.2, maxmin:true, shadeClose:true, move:false,area: ['1000px', '100%'],offset:  'rt', anim: 2, content: url , btn: false
            });
        });

       // 账单列表 end
        // 租赁日志 add
        var tableContractLogListId = 'contractLogList';
        table.render({
            elem: '#'+tableContractLogListId,
            id:tableContractLogListId,
            url: '{:url("propertyContractLogList")}?contract_id='+contractId,
            cols: [[
                {field: 'add_time', width: 168, title: '创建时间', sort: true},
                {field: 'username', width: 108, title: '执行用户', sort: true},
                {field: 'remark', minWidth: 100, title: '备注说明'},
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 15,
            page: true,
            height: 'full-110'
        });
        // 租赁日志 end 
        // 关联房间列表 add 
        var tableRoomContractListId = 'roomContractList';
        table.render({
            elem: '#'+tableRoomContractListId,
            id:tableRoomContractListId,
            url: '{:url("propertyRoomBasicList")}?contract_id='+contractId,
            cols: [[
                {field: 'full_room_name', minWidth: 208, title: '房间信息'},
                {title: '操作', minWidth: 88, toolbar: '#tableRoomContractBar', fixed:'right'}
            ]],
        });

        table.on('tool('+tableRoomContractListId+')', function (obj) {
            var data = obj.data;
            if (obj.event === 'roomRelieve') {
                var url = '{:url("propertyContractRoomRelieve")}';
                layer.confirm('解除关联！  是否确认? ', {icon: 3}, function () {
                    var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                    $.post(url, {id: data.id}, function (res) {
                        layer.close(loadAdd);
                        if (res.code === 0) {
                            table.reload(tableRoomContractListId); //数据刷新
                            layer.msg(res.msg, {icon: 6, offset: '15px'});
                        } else {
                            layer.msg(res.msg, {icon: 5, offset: '15px'});
                        }
                    });
                });
            } else if (obj.event === 'roomDetail') {
                var url = '{:url("propertyRoomBasicDetail")}?room_id='+data.id;
                var index = parent.layer.open({title: data.full_room_name + ' 详情 ',  type: 2, shade: 0.2,maxmin: true, shadeClose: true,   move: false, area: ['1050px', '100%'], offset: 'rt',  anim: 2,  content: url,  btn: false  });
                return false;
            }
        });
        // 关联房间列表 end

        // 合同费用列表 add
        $('.contractBillAdd').on('click', function() {
            var url = '{:url("propertyContractBillAdd")}?contract_id='+contractId;
            var index = layer.open({title: '添加费用', type: 2, shade: 0.2,maxmin:true, area:['600px', '500px'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                    var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                    iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                        var field = data.field; //获取提交的字段
                        var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                        $.post(url, field, function (res) {
                            layer.close(loadAdd);
                            if (res.code === 0) {
                                location.reload();//刷新当前页
                                layer.close(index); //关闭弹层
                                layer.msg(res.msg, {icon: 6, offset: '15px'});
                            } else {
                                layer.msg(res.msg, {icon: 5, offset: '15px'});
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        });

        var tableContractBillDataId = 'contractBillData';
        table.render({
            elem: '#'+tableContractBillDataId,
            id:tableContractBillDataId,
            url: '{:url("propertyContractBillList")}?contract_id='+contractId,
            cols: [[
                {field: 'cate_name', width: 128, title: '费用名称'},
                {field: 'pay_type', width: 108, title: '支付方式'},
                {field: 'amount', width: 108, title: '金额'},
                {field: 'status', width: 102, title: '执行状态', templet:'#contract_bill_status_tpl', sort: true, align: "center"},
                {field: 'remark', width: 208, title: '备注'},
                {title: '操作', minWidth: 88, toolbar: '#tableContractBillDataBar', fixed:'right'}
            ]],
        });
        table.on('tool('+tableContractBillDataId+')', function (obj) {
            var data = obj.data;
            if(obj.event === 'contractBillDataEdit'){
                var url = '{:url("propertyContractBillEdit")}?id='+data.id
                var index = layer.open({ title: '编辑',type: 2,shade: 0.2,maxmin: true, area: ['600px', '500px'], content: url, btnAlign: 'c',btn: ['确定','取消'], yes: function( index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index],submit = layero.find('iframe').contents().find("#submitBtn");
                        iframeWindow.layui.form.on('submit(submitBtn)', function(data){
                            var field = data.field //获取提交的字段
                            var loadAdd = layer.msg('提交中',{icon: 16, time: 0, shade: 0.1, offset: '15px'})
                            $.post(url, field, function(res){
                                layer.close(loadAdd);
                                if (res.code === 0) {
                                    table.reload(tableContractBillDataId); //数据刷新
                                    layer.close(index); //关闭弹层
                                    layer.msg(res.msg, {icon: 6, offset: '15px'});
                                } else {
                                    layer.msg(res.msg, {icon: 5, offset: '15px'});
                                }
                            })
                        })
                        submit.trigger('click')
                    }
                })
                $(window).on("resize", function(){
                    layer.full(index)
                })
                return false
            } else if (obj.event === 'contractBillDataDel') {
                var url = '{:url("propertyContractBillDel")}';
                layer.confirm('删除费用！  是否确认? ', {icon: 3}, function () {
                    var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                    $.post(url, {ids: [data.id]}, function (res) {
                        layer.close(loadAdd);
                        if (res.code === 0) {
                            table.reload(tableContractBillDataId); //数据刷新
                            layer.msg(res.msg, {icon: 6, offset: '15px'});
                        } else {
                            layer.msg(res.msg, {icon: 5, offset: '15px'});
                        }
                    });
                });
            }
        });
        // 合同费用列表 end

        // 同住用户列表 add
        $('.contractLesseeAdd').on('click', function() {
            var url = '{:url("propertyContractLesseeAdd")}?contract_id='+contractId;
            var index = layer.open({title: '添加同住用户', type: 2, shade: 0.2,maxmin:true, area:['600px', '500px'], content: url, btnAlign: 'c', btn: ['确定', '取消'], yes: function (index, layero) {
                    var iframeWindow = window['layui-layer-iframe' + index], submit = layero.find('iframe').contents().find("#submitBtn");
                    iframeWindow.layui.form.on('submit(submitBtn)', function (data) {
                        var field = data.field; //获取提交的字段
                        var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                        $.post(url, field, function (res) {
                            layer.close(loadAdd);
                            if (res.code === 0) {
                                location.reload();//刷新当前页
                                layer.close(index); //关闭弹层
                                layer.msg(res.msg, {icon: 6, offset: '15px'});
                            } else {
                                layer.msg(res.msg, {icon: 5, offset: '15px'});
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        });

        var tableContractLesseeDataId = 'contractLesseeList';
        table.render({
            elem: '#'+tableContractLesseeDataId,
            id:tableContractLesseeDataId,
            url: '{:url("propertyContractLesseeList")}?contract_id='+contractId,
            cols: [[
                {field: 'username', width: 128, title: '用户姓名', templet:'#room_name_tpl'},
                {field: 'mobile', width: 128, title: '联系电话', sort: true},
                {field: 'is_type', width: 250, title: '证件号码', templet:'#is_type_tpl', sort: true},
                {field: 'is_owner', width: 108, title: '身份特征', templet:'#is_owner_tpl', sort: true},
                {field: 'remark', minWidth: 128, title: '备注说明',  sort: true},
                {title: '操作', width: 168, toolbar: '#tableContractLesseeDataBar', fixed:'right'}
            ]],
        });
        table.on('tool('+tableContractLesseeDataId+')', function (obj) {
            var data = obj.data;
            if(obj.event === 'contractLesseeEdit'){
                var url = '{:url("propertyContractLesseeEdit")}?id='+data.id
                var index = layer.open({ title: '编辑用户信息',type: 2,shade: 0.2,maxmin: true, area: ['600px', '500px'], content: url, btnAlign: 'c',btn: ['确定','取消'], yes: function( index, layero) {
                        var iframeWindow = window['layui-layer-iframe' + index],submit = layero.find('iframe').contents().find("#submitBtn");
                        iframeWindow.layui.form.on('submit(submitBtn)', function(data){
                            var field = data.field //获取提交的字段
                            var loadAdd = layer.msg('提交中',{icon: 16, time: 0, shade: 0.1, offset: '15px'})
                            $.post(url, field, function(res){
                                layer.close(loadAdd);
                                if (res.code === 0) {
                                    table.reload(tableContractLesseeDataId); //数据刷新
                                    layer.close(index); //关闭弹层
                                    layer.msg(res.msg, {icon: 6, offset: '15px'});
                                } else {
                                    layer.msg(res.msg, {icon: 5, offset: '15px'});
                                }
                            })
                        })
                        submit.trigger('click')
                    }
                })
                $(window).on("resize", function(){
                    layer.full(index)
                })
                return false
            } else if (obj.event === 'contractLesseeDetail') {
                var url = '{:url("propertyContractLesseeDetail")}?id='+data.id;
                var index = parent.layer.open({title: data.username + ' 资料详情 ',  type: 2, shade: 0.2,maxmin: true, shadeClose: true,   move: false, area: ['600px', '60%'], offset: 'rt',  anim: 2,  content: url,  btn: false  });
                return false;
            } else if (obj.event === 'contractLesseeDel') {
                var url = '{:url("propertyContractLesseeDel")}';
                layer.confirm('删除同住用户！  是否确认? ', {icon: 3}, function () {
                    var loadAdd = layer.msg('提交中', {icon: 16, time: 0, shade: 0.1, offset: '15px'});
                    $.post(url, {ids: [data.id]}, function (res) {
                        layer.close(loadAdd);
                        if (res.code === 0) {
                            table.reload(tableContractLesseeDataId); //数据刷新
                            layer.msg(res.msg, {icon: 6, offset: '15px'});
                        } else {
                            layer.msg(res.msg, {icon: 5, offset: '15px'});
                        }
                    });
                });
            }
        });
        // 同住用户列表 end

    });
</script>
{/block}